package 数组.独一无二出现次数;

import java.io.Serializable;
import java.util.*;

/**
 * @author: wh(1835734390 @ qq.com)
 * @date: 2023/2/27 16:49
 * @description:
 * @version:
 */
public class Solution {
    public static void main(String[] args) {
        int[] arr = {1,2,2,1,1,3};
        System.out.println(uniqueOccurrences(arr));
    }


    public static boolean uniqueOccurrences(int[] arr) {
        Map<Integer,Integer> map = new HashMap<>();
        for (int i = 0; i < arr.length; i++) {
            map.put(arr[i],map.getOrDefault(arr[i],0) + 1);
        }
        Collection<Integer> values = map.values();

        //list转set实现去重
        Set<Integer> set = new HashSet<>(values);
        return map.size() == set.size();
    }
}
